import {api1} from "@/common/api/request";
import {Toast} from "mint-ui";
export default {
  state:{
    list:[],
  },
  getters:{

  },
  mutations:{
    //请求到的数据进行赋值 state.list
    initGetData(state,pathList){
      state.list = pathList
    },
    deleteAddress(state,id){
      state.list = state.list.filter(v=>{
        return v.id != id
      })
    },
  },
  actions:{
    deleteAddressFn({commit},id) {
      api1({
        url: '/api/deleteAddress',
        method: 'POST',
        headers: {
          token: true
        },
        data: {
          id
        }
      }).then(res => {
        if (res.success) {
          commit('deleteAddress', id)
          Toast(res.msg)
        }
      })
    }
  }
}